﻿<sdk:Page x:Class="SampleBrowser.Views.SampleContextMenu" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:doc="http://schemas.firstfloorsoftware.com/documenttoolkit"
           xmlns:dte="http://schemas.firstfloorsoftware.com/documenttoolkit/extensions"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Context Menu and Commands">
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="136" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.Resources>
            <doc:TextSelection x:Key="Selection" IsEnabled="True" />
        </Grid.Resources>

        <TextBlock x:Name="HeaderText" Grid.ColumnSpan="2" Style="{StaticResource HeaderTextStyle}" Text="Context Menu and Commands"/>
        <TextBlock Grid.Row="1" Grid.ColumnSpan="2" Text="Select some text and right mouse click to display the context menu" Margin="0,0,0,4" />

        <doc:DocumentDataSource x:Name="DataSource" LoadError="DataSource_LoadError" />

        <doc:ThumbnailListBox x:Name="Thumbnails" Grid.Row="2" DocumentDataSource="{Binding ElementName=DataSource}" PageIndex="{Binding PageIndex, Mode=TwoWay, ElementName=Navigator}" />
        
        <doc:DocumentViewer x:Name="Viewer"
                            Grid.Column="1" Grid.Row="2"
                            DocumentDataSource="{Binding ElementName=DataSource}"
                            Selection="{StaticResource Selection}"
                            ViewMode="{Binding SelectedViewMode, ElementName=ViewModePicker}">
            <toolkit:ContextMenuService.ContextMenu>
                <toolkit:ContextMenu>
                    <toolkit:MenuItem Header="Copy">
                        <toolkit:MenuItem.Icon>
                            <Image Source="/SampleBrowser;component/Assets/Icons/copy.png" />
                        </toolkit:MenuItem.Icon>
                        <toolkit:MenuItem.Command>
                            <doc:CopyToClipboardCommand Selection="{StaticResource Selection}" />
                        </toolkit:MenuItem.Command>
                    </toolkit:MenuItem>
                    <toolkit:Separator />
                    <toolkit:MenuItem Header="Highlight selection">
                        <toolkit:MenuItem.Icon>
                            <Image Source="/SampleBrowser;component/Assets/Icons/highlight.png" />
                        </toolkit:MenuItem.Icon>
                        <toolkit:MenuItem.Command>
                            <doc:HighlightCommand Selection="{StaticResource Selection}" />
                        </toolkit:MenuItem.Command>
                    </toolkit:MenuItem>
                    <toolkit:MenuItem Header="Remove highlight">
                        <toolkit:MenuItem.Command>
                            <doc:ClearHighlightCommand Selection="{StaticResource Selection}" />
                        </toolkit:MenuItem.Command>
                    </toolkit:MenuItem>
                    <toolkit:Separator />
                    <toolkit:MenuItem Header="Select page">
                        <toolkit:MenuItem.Command>
                            <doc:SelectPageCommand Selection="{StaticResource Selection}" />
                        </toolkit:MenuItem.Command>
                    </toolkit:MenuItem>
                    <toolkit:MenuItem Header="Select document">
                        <toolkit:MenuItem.Command>
                            <doc:SelectDocumentCommand Selection="{StaticResource Selection}" />
                        </toolkit:MenuItem.Command>
                    </toolkit:MenuItem>
                    <toolkit:MenuItem Header="Unselect">
                        <toolkit:MenuItem.Command>
                            <doc:UnselectCommand Selection="{StaticResource Selection}" />
                        </toolkit:MenuItem.Command>
                    </toolkit:MenuItem>
                    <toolkit:Separator />
                    <toolkit:MenuItem Header="Search with Bing">
                        <toolkit:MenuItem.Icon>
                            <Image Source="/SampleBrowser;component/Assets/Icons/bing.png" />
                        </toolkit:MenuItem.Icon>
                        <toolkit:MenuItem.Command>
                            <doc:NavigateSelectionCommand LinkFormat="http://www.bing.com/search?q={0}" Selection="{StaticResource Selection}" />
                        </toolkit:MenuItem.Command>
                    </toolkit:MenuItem>
                    <toolkit:MenuItem Header="Search with Google">
                        <toolkit:MenuItem.Icon>
                            <Image Source="/SampleBrowser;component/Assets/Icons/google.png" />
                        </toolkit:MenuItem.Icon>
                        <toolkit:MenuItem.Command>
                            <doc:NavigateSelectionCommand LinkFormat="http://www.google.com/search?q={0}" Selection="{StaticResource Selection}" />
                        </toolkit:MenuItem.Command>
                    </toolkit:MenuItem>
                </toolkit:ContextMenu>
            </toolkit:ContextMenuService.ContextMenu>
        </doc:DocumentViewer>

        <StackPanel Grid.ColumnSpan="2" Grid.Row="3" Orientation="Horizontal" Margin="0,8,0,0" HorizontalAlignment="Center">
            <doc:HistoryNavigator History="{Binding History, ElementName=Viewer}" />
            <doc:PageNavigator x:Name="Navigator"
                               PageCount="{Binding PageCount, ElementName=Viewer}"
                               PageIndex="{Binding PageIndex, ElementName=Viewer, Mode=TwoWay}"
                               Margin="4,0,0,0" />
            <doc:ViewModePicker x:Name="ViewModePicker" Margin="4,0,0,0" />
            <Button Margin="4,0,0,0" Padding="7">
                <Button.Command>
                    <dte:OpenPdfOrXpsFromDiskCommand DocumentDataSource="{Binding ElementName=DataSource}" />
                </Button.Command>
                <Button.Content>
                    <Image Source="/SampleBrowser;component/Assets/Icons/open.png" />
                </Button.Content>
            </Button>

        </StackPanel>
    </Grid>
</sdk:Page>
